import Buff from '@/Buff';
import BuffUtil from '@/BuffUtil';
import SelectUtil from '@/SelectUtil';
import BuffCommon from 'code/Core/Common/BuffCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 剑刃风暴
 **/
export default class ZS_BladeStrom extends AbilityBase {
    static instance: ZS_BladeStrom;
    buffType: AppBuffType = {
        id: 'buff_ZS_BladeStrom',
        art: this.art,
        name: this.abilityName,
        ubertip: '',
        onInterval: this.buffInterval.bind(this),
        interval: 1,
        dur: 6,
        // targetArt: '召唤叶片\\sem_zhao_huan_ye_pian.mdx',
        targetArt: 'BladeStorm\\BloodTornado.mdx',
        targetAttach: 'origin',
    };
    constructor(id: string = 'Ajrb') {
        super(id);
        ZS_BladeStrom.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        // BuffUtil.addBuff(source, this.buffType.id, source);
        BuffCommon.addBuff({ target: source, caster: source, buffTypeId: this.buffType.id, ablityId: this.id });
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
    buffInterval(buff: Buff) {
        let lv = this.getAbilityLevel(buff.getCaster());
        let dmg = 35 * lv + UnitCommon.取攻击(buff.getCaster()) * (0.5 + 0.2 * lv);
        let es = SelectUtil.getEnemyUnitsInRange(buff.getCaster(), 225);
        DamageSystemInstance.applyAoeMagicDamage(es, buff.getCaster(), dmg, 'wind', this.id);
    }
}
